package informed.samples;

import java.util.ArrayList;

import informed.io.ReadSparseMatrix;
import cern.colt.matrix.DoubleMatrix1D;
import cern.colt.matrix.DoubleMatrix2D;

public class LinearRegressionSample implements Sample{
	
	public int id;
	public double y;
	public DoubleMatrix1D x;
	
	public static ArrayList<Sample> loadSamples(String fileX, String fileY){
		ReadSparseMatrix reader = new ReadSparseMatrix();
		DoubleMatrix2D x = reader.read(fileX);
		DoubleMatrix2D y = reader.read(fileY);
		ArrayList<Sample> samples = new ArrayList<Sample>();
		for(int i = 0; i < x.rows(); i++){
			LinearRegressionSample s = new LinearRegressionSample();
			s.y = y.get(i, 0);
			s.x = x.viewRow(i);
			s.id = i;
			samples.add(s);
		}
		return samples;
	}

}
